package com.mabs.ground.core;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.mabs.ground.core.model.ModelObject;
import com.mabs.ground.shared.DataResponseBean;
import com.mabs.ground.shared.model.ModelBean;

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class DataResponse<T extends ModelBean> extends ModelObject implements
		DataResponseBean<T>, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4125297103418401136L;

	@XmlAnyElement
	private List<T> data;

	private Integer startRow;

	private Integer endRow;

	private Integer totalRows;

	public List<T> getData() {
		if (data == null) {
			data = new ArrayList<T>();
		}
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
		this.startRow = 0;
		this.endRow = data.size() - 1;
		this.totalRows = data.size();

	}

	public Integer getStartRow() {
		return startRow;
	}

	public Integer getEndRow() {
		return endRow;
	}

	public Integer getTotalRows() {
		return totalRows;
	}

	@Override
	public Serializable getId() {
		// TODO Auto-generated method stub
		return null;
	}

}
